package team.you.ticket.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import team.you.ticket.pojo.Result;
import team.you.ticket.service.UserService;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/userInfo")
public class IndexController
{
    @Autowired
    private UserService userService;

    @RequestMapping("/getAllUsers")
    @ResponseBody
    private Result getAllUsers(Integer page,Integer limit)
    {
        return userService.getAllUsers(page,limit);
    }
    @RequestMapping("/del")
    @ResponseBody
    private Result del(String id)
    {
        return userService.del(id);
    }
    @RequestMapping("/delete")
    @ResponseBody
    private Result delete(String[] ids)
    {
        return userService.delete(ids);
    }
    @RequestMapping("/update")
    @ResponseBody
    private Result update(String id,String value,String field)
    {
        return userService.update(id,value,field);
    }
    @RequestMapping("/selectByLike")
    @ResponseBody
    private Result selectByLike(String value,String type,Integer page,Integer limit)
    {
        if (type=="")
            type="3";
        return userService.selectByLike(value,type,page,limit);
    }
    @RequestMapping("/pwd")
    @ResponseBody
    private Result pwd(String username, String mobileCode, HttpServletRequest request)
    {
        return userService.pwd(username,mobileCode,request);
    }
    @ResponseBody
    @RequestMapping("/code")
    private Result code(String username,HttpServletRequest request)
    {
        return userService.getCode(username,request);
    }
    @ResponseBody
    @RequestMapping("/updateInfoCode")
    private Result updateInfoCode(String id,HttpServletRequest request)
    {
        Result result=new Result();
        result.setMsg("验证码发送成功");
        return  result;//userService.updateInfoCode(id,request);
    }
    @ResponseBody
    @RequestMapping("/updateInfo")
    private Result updateInfo(String id,String mobileCode,String username,String password,String phone,String papers,String remarks,HttpServletRequest request)
    {
        return userService.updateInfo(id,mobileCode,username,password,phone,papers,remarks,request);
    }
    @RequestMapping("/InfoLoad")
    @ResponseBody
    private Result InfoLoad(String userid)
    {
        return userService.InfoLoad(userid);
    }
}
